package javacode.chapter05.exer;

public class Exercise03 {
    public static void main(String[] args) {
        // 编程实现两个矩阵相加
        int[][] a = {{3, 4, 1, 2}, {2, 6, 0, 7}, {0, 3, 2, 3}};
        int[][] b = {{1, 8, 9, 0}, {5, 4, 3, 6}, {6, 5, 2, 4}};
        int[][] c = new int[a.length][a[0].length];
        // 1.实现两个矩阵对应位置上元素的相加
        for (int i = 0; i < c.length; i++) {
            for (int j = 0; j < c[i].length; j++) {
                c[i][j] = a[i][j] + b[i][j];
            }
        }
        // 2.打印相加以后的矩阵
        for (int i = 0; i < c.length; i++) {
            for (int j = 0; j < c[i].length; j++) {
                System.out.print(c[i][j] + " ");
            }
            System.out.println();
        }
    }
}
